package com.gengzp.rpc.model.resp;

import java.io.Serial;
import java.io.Serializable;

/**
 * @ClassName RpcRequestResult
 * @Description
 * @Author gengzp
 * @Date 2025/6/1 1:22
 */
public class RpcRequestResult implements Serializable {

    @Serial
    private static final long serialVersionUID = 8622354546443722459L;

    /**
     * 请求是否成功标识
     */
    private Boolean isSuccess = true;

    /**
     * 请求失败信息
     */
    private String errorMessage;

    /**
     * 返回信息
     */
    private Object data;

    private RpcRequestResult() {
    }

    /**
     * 请求成功
     */
    public static RpcRequestResult getSuccessResult() {
        return new RpcRequestResult();
    }

    /**
     * 请求成功
     *
     * @param data 返回数据
     */
    public static RpcRequestResult getSuccessResult(Object data) {
        RpcRequestResult rpcRequestResult = new RpcRequestResult();
        rpcRequestResult.setData(data);
        return rpcRequestResult;
    }

    /**
     * 请求失败
     *
     * @param errorMessage 错误原因
     */
    public static RpcRequestResult getFailResult(String errorMessage) {
        RpcRequestResult rpcRequestResult = new RpcRequestResult();
        rpcRequestResult.setSuccess(false);
        rpcRequestResult.setErrorMessage(errorMessage);
        return rpcRequestResult;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Boolean getSuccess() {
        return isSuccess;
    }

    public void setSuccess(Boolean success) {
        isSuccess = success;
    }

}
